package com.example.star.service;

import com.example.star.entity.Favorite;
import com.example.star.entity.Feedback;
import com.example.star.entity.Reply;
import com.example.star.mapper.ReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReplyService {
    @Autowired
    private ReplyMapper replyMapper;

    public void createReply(Reply reply) {
        replyMapper.insertReply(reply);
    }
    public List<Reply> getAllReply() {
        return replyMapper.getAllReply();
    }

    public List<Reply> getRepliesByUserName(String userName) {
        return replyMapper.getRepliesByUserName(userName);
    }

    public List<Reply> getReplyByPage(int page, int size) {
        int offset = (page - 1) * size;
        return replyMapper.getReplyByPage(offset, size);
    }
    public int getTotalReply() {
        return replyMapper.getTotalReply();
    }

    public void deleteReplyById(int id) {
        replyMapper.deleteReplyById(id);
    }

    public List<Reply> getRepliesByUserNameAndPage(String userName, int page, int size) {
        int offset = (page - 1) * size;
        return replyMapper.getRepliesByUserNameAndPage(userName, offset, size);
    }

    public int getTotalRepliesByUserName(String userName) {
        return replyMapper.getTotalRepliesByUserName(userName);
    }
}
